//
//  CCVSHeader.m
//  ClinicalCollections
//
//  Created by Pasirstein, David B on 4/6/13.
//  Copyright (c) 2013 GOPI. All rights reserved.
//

#import "CCVSHeader.h"

@implementation CCVSHeader

@synthesize headerString = _headerString;
@synthesize isCVTitle = _isCVTitle;
@synthesize label = _label;


//A Header can be either the top Title or the name
//of a subsection.  We want to differenciate
-(void)setIsCVTitle:(BOOL)isCVTitle
{
    _isCVTitle = isCVTitle;
    if (_isCVTitle == NO) {
        self.label.font = [UIFont fontWithName:@CCVS_SECTION_FONTNAME size:CCVS_SECTION_FONTSIZE];
    } else {
        self.label.font = [UIFont fontWithName:@CCVS_TITLE_FONTNAME size:CCVS_TITLE_FONTSIZE];
    }
}

-(void)setHeaderString:(NSString *)headerString
{
    if ([@"-" isEqualToString:headerString]) {
        //we have a divider, not a header
        _headerString = @"";
    } else {
        _headerString = headerString;
    }
    //resize the label to fit the space provided to us
    self.label.frame = CGRectMake(0, 0, self.viewForBaselineLayout.frame.size.width, self.viewForBaselineLayout.frame.size.height);
    self.isCVTitle = _isCVTitle; //double check the properties are set
    self.label.text = _headerString;  //set the string value to display
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
